home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14324 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Looking for date & distance routines
  5. Date: Sat, 13 Apr 96 14:01:10 GMT
  6. Organization: none
  7. Message-ID: <829404070snz@genesis.demon.co.uk>
  8. References: <4kn6e7$ba9@ux.accesscom.net> <4kns53$ge2@nntp.Stanford.EDU>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4kns53$ge2@nntp.Stanford.EDU>
  15.            karish@pangea.Stanford.EDU "Chuck Karish" writes:
  16.  
  17. >In article <4kn6e7$ba9@ux.accesscom.net>, Wisdom <wisdom@wisdom.com> wrote:
  18. >>
  19. >>I'm in search of two sets of routines:
  20. >>
  21. >>  1.  Code to calculate the amount of days between two time_t-type
  22. >>date variables, and a routine to return a date x days from a specified
  23. >>time_t structure.
  24. >
  25. >On what type of system?  If your C library has mktime(), it will
  26. >convert data in a struct tm into a time_t, at which point you can
  27. >subtract and divide by 84600.
  28.  
  29. You can't subtract two time_t values directly to give anything meaningful
  30. since the representation of time_t is not specified. You use difftime()
  31. to get the difference between two time_t values in seconds. You can then
  32. divide that by 86400 (not 84600) if that makes sense. Remember that there
  33. aren't always 24 hours in a day (changes to and from daylight saving time)
  34. and 23:59 and 2 minutes later are in different days.
  35.  
  36. The problem needs to be specified more precisely to determine an
  37. appropriate solution.
  38.  
  39. -- 
  40. -----------------------------------------
  41. Lawrence Kirby | fred@genesis.demon.co.uk
  42. Wilts, England | 70734.126@compuserve.com
  43. -----------------------------------------
  44.